/*
 * Project Name: tennis
 * $Id:  PlayService.java 2016-05-13 15:26:41 $
 */

package org.aceor.tennis.service;

import com.google.common.base.Optional;
import org.aceor.tennis.common.domain.BaseDomain;
import org.aceor.tennis.common.domain.Play;
import org.aceor.tennis.common.exception.BusinessRuntimeException;

import java.util.List;

public interface IPlayService<T extends BaseDomain> extends IBaseService<T>{

    /**
     * 查询进行中的球局(排除掉已取消和已结束的球局)
     * @param offset
     * @param rows
     * @return
     */
    List<Play> queryUnderwayPlays(Integer offset, Integer rows) throws BusinessRuntimeException;

    /**
     * 查询所有进行中的球局
     * @return
     */
    List<Play> queryAllUnderwayPlays() throws BusinessRuntimeException;

    /**
     * 查询自己创建+被同意加入其他人的球局
     * @param userId
     * @return
     * @throws BusinessRuntimeException
     */
    List<Play> queryAllSelfCreatePlays(Long userId) throws BusinessRuntimeException;

    /**
     * 取消球局
     * @param playId
     * @throws BusinessRuntimeException
     */
    void cancelOnePlay(Long playId) throws BusinessRuntimeException;

    Optional<Play> findOneById(Long id) throws BusinessRuntimeException;
}
